class Equipment {
	constructor() {
		this._atk = 0;
		this._def = 0;
		this._hp = 0;
		this._sp = 0;
		this._speed = 0;
		this._range = 0;
		this._keep = 0;
		this._weight = 0;
		this._location = 0;
	}
	
	/**
	 * 获取装备添加的HP
	 */
	get hp() {
		return this._hp;
	}
	
	/**
	 * 设置装备添加的HP
	 */
	set hp(value) {
		this._hp = value;
	}
	
	/**
	 * 获取装备添加的SP
	 */
	get sp() {
		return this._sp;
	}
	
	/**
	 * 设置装备添加的SP
	 */
	set sp(value) {
		this._sp = value;
	}
	
	/**
	 * 获取装备防御力
	 */
	get def() {
		return this._def;
	}
	
	/**
	 * 设置装备防御力
	 */
	set def(value) {
		return this._def;
	}
	
	/**
	 * 获取装备攻击力
	 */
	get atk() {
		return this._atk;
	}
	
	/**
	 * 设置装备攻击力
	 */
	set atk(value) {
		this._atk = value;
	}
	
	/**
	 * 获取装备增加的移动速度
	 */
	get speed() {
		return this._speed;
	}
	
	/**
	 * 设置装备增加的移动速度
	 */
	set speed(value) {
		this._speed = value;
	}
	
	/**
	 * 获取装备增加攻击持续时间
	 */
	get keep() {
		return this._keep;
	}
	
	/**
	 * 设置装备增加攻击持续时间
	 */
	set keep(value) {
		this._keep = value;
	}
	
	/**
	 * 获取装备攻击范围加成
	 */
	get range() {
		return this._range;
	}
	
	/**
	 * 设置装备攻击范围加成
	 */
	set range(value) {
		this._range = value;
	}
	
	/**
	 * 获取装备重量
	 */
	get weight() {
		return this._weight;
	}
	
	/**
	 * 设置装备重量
	 */
	set weight(value) {
		this._weight = value;	
	}
	
	/**
	 * 获取装备位置
	 */
	get location() {
		return this._location;
	}
	
	/**
	 * 设置装备位置
	 */
	set location(value) {
		this._location = value;
	}
	
	/**
	 * 应用装备给角色
	 */
	apply(character) {
		// 获取已装备道具
		const equip = character.equipments[this.location];
		
		// 如果存在已装备道具则脱下(重新计算属性)
		if(equip) {
			character.hp -= equip.hp;
			character.sp -= equip.sp;
			character.atk -= equip.atk;
			character.def -= equip.def;
			character.speed -= equip.speed;
			character.keep -= equip.keep;
			character.range -= equip.range;
			character.weight -= equip.weight; 
		}
		
		// 重新计算角色属性
		character.hp += this.hp;
		character.sp += this.sp;
		character.atk += this.atk;
		character.def += this.def;
		character.speed += this.speed;
		character.keep = += this.keep;
		character.range = += this.range;
		character.weight += this.weight; 
	}
}